/// @author: cairuoyu
/// @homepage: http://cairuoyu.com
/// @github: https://github.com/cairuoyu/flutter_admin
/// @date: 2021/6/21
/// @version: 1.0
/// @description:
import 'package:flutter/material.dart';
import 'package:flutter_admin/models/tab_page.dart';
import 'package:flutter_admin/pages/article/article_main.dart';
import 'package:flutter_admin/pages/charts/s_area_age_gender/s_area_age_gender_main.dart';
import 'package:flutter_admin/pages/common/cry/common/bindings/common_bindings.dart';
import 'package:flutter_admin/pages/common/cry/cry.dart';
import 'package:flutter_admin/pages/common/only_text.dart';
import 'package:flutter_admin/pages/common/page_401.dart';
import 'package:flutter_admin/pages/common/page_404.dart';
import 'package:flutter_admin/pages/dash/dashboard.dart';
import 'package:flutter_admin/pages/dept/dept_main.dart';
import 'package:flutter_admin/pages/dict/dict_list.dart';
import 'package:flutter_admin/pages/image/image_upload.dart';
import 'package:flutter_admin/pages/large_screen/kanban_management.dart';
import 'package:flutter_admin/pages/layout/layout.dart';
import 'package:flutter_admin/pages/login.dart';
import 'package:flutter_admin/pages/menu/menu_main.dart';
import 'package:flutter_admin/pages/message/message_main.dart';
import 'package:flutter_admin/pages/odoo/base_dictionarydata/base_dictionarydata_list.dart';
import 'package:flutter_admin/pages/odoo/base_productionstation/base_productionstation_print_list.dart';
import 'package:flutter_admin/pages/odoo/base_team/base_team_list.dart';
import 'package:flutter_admin/pages/odoo/dms_documentlocation/dms_documentlocation_list.dart';
import 'package:flutter_admin/pages/odoo/dms_documenttype/dms_documenttype_list.dart';
import 'package:flutter_admin/pages/odoo/dms_userqualifications/dms_userqualifications_list.dart';
import 'package:flutter_admin/pages/odoo/material/ERP_search_on_time_list.dart';
import 'package:flutter_admin/pages/odoo/material/company_material_search/company_material_search_list.dart';
import 'package:flutter_admin/pages/odoo/material/cpk_print/cpk_print.dart';
import 'package:flutter_admin/pages/odoo/material/finished_in/finished_in_list.dart';
import 'package:flutter_admin/pages/odoo/material/finished_out/finished_out_list.dart';
import 'package:flutter_admin/pages/odoo/material/hw_check/hw_check_list.dart';
import 'package:flutter_admin/pages/odoo/material/hw_quant_search/hw_quant_search_list.dart';
import 'package:flutter_admin/pages/odoo/material/location_in/location_in_list.dart';
import 'package:flutter_admin/pages/odoo/material/location_in_search/location_in_search_list.dart';
import 'package:flutter_admin/pages/odoo/material/location_out/location_out_list.dart';
import 'package:flutter_admin/pages/odoo/material/location_out_search/location_out_search_list.dart';
import 'package:flutter_admin/pages/odoo/material/price_trend/price_trend_list.dart';
import 'package:flutter_admin/pages/odoo/material/stock_picking_finished/stock_picking_finished_list.dart';
import 'package:flutter_admin/pages/odoo/material/stock_quant/stock_quant_search_list.dart';
import 'package:flutter_admin/pages/odoo/material/stores_requisition/stores_requisition_list.dart';
import 'package:flutter_admin/pages/odoo/material/workshop_material/workshop_material_list.dart';
import 'package:flutter_admin/pages/odoo/material/workshop_picking/workshop_picking_list.dart';
import 'package:flutter_admin/pages/odoo/material/workshop_transfer/workshop_transfer_list.dart';
import 'package:flutter_admin/pages/odoo/material/workshop_transfer/workshop_transfer_search.dart';
import 'package:flutter_admin/pages/odoo/mps_demand_line/mps_demand_line_list.dart';
import 'package:flutter_admin/pages/odoo/mps_order_line/mps_order_line_list.dart';
import 'package:flutter_admin/pages/odoo/mps_replenishment/mps_replenishment_list.dart';
import 'package:flutter_admin/pages/odoo/mps_transit/mps_transit_list.dart';
import 'package:flutter_admin/pages/odoo/mrp_production/mrp_production_list.dart';
import 'package:flutter_admin/pages/odoo/mrp_production_check/mrp_production_check_list.dart';
import 'package:flutter_admin/pages/odoo/product_electroncheckrecord/product_electroncheckrecord_list.dart';
import 'package:flutter_admin/pages/odoo/product_equhisdata/product_equhisdata_list.dart';
import 'package:flutter_admin/pages/odoo/product_plateconsumption/product_plateconsumption_list.dart';
import 'package:flutter_admin/pages/odoo/product_productionorder/product_productionorder_list.dart';
import 'package:flutter_admin/pages/odoo/product_productmouldquota/product_productmouldquota_list.dart';
import 'package:flutter_admin/pages/odoo/product_productunitprice/product_productunitprice_list.dart';
import 'package:flutter_admin/pages/odoo/product_stockorder/product_stockorder_list.dart';
import 'package:flutter_admin/pages/odoo/product_stockorder_supplement/product_stockorder_supplement_list.dart';
import 'package:flutter_admin/pages/odoo/product_template/print/product_template_print_list.dart';
import 'package:flutter_admin/pages/odoo/product_template/product_template_list.dart';
import 'package:flutter_admin/pages/odoo/product_userhourcost/product_userhourcost_list.dart';
import 'package:flutter_admin/pages/odoo/product_usermeritpay/product_usermeritpay_list.dart';
import 'package:flutter_admin/pages/odoo/product_userpostratio/product_userpostratio_list.dart';
import 'package:flutter_admin/pages/odoo/product_workreportrecord/product_workreportrecord_list.dart';
import 'package:flutter_admin/pages/odoo/purchase_evaluation_project/purchase_evaluation_project_table_list.dart';
import 'package:flutter_admin/pages/odoo/purchase_evaluation_template/purchase_evaluation_template_list.dart';
import 'package:flutter_admin/pages/odoo/purchase_order/purchase_order_list.dart';
import 'package:flutter_admin/pages/odoo/purchase_quality_problem/purchase_quality_problem_list.dart';
import 'package:flutter_admin/pages/odoo/purchase_supplier_evaluation/evaluation_analysis_list.dart';
import 'package:flutter_admin/pages/odoo/purchase_supplier_evaluation/purchase_supplier_evaluation_list.dart';
import 'package:flutter_admin/pages/odoo/purchase_supplier_evaluation/purchase_supplier_evaluation_template.dart';
import 'package:flutter_admin/pages/odoo/purchase_supplier_level/purchase_supplier_level_list.dart';
import 'package:flutter_admin/pages/odoo/quant_warning_line/quant_warning_line_list.dart';
import 'package:flutter_admin/pages/odoo/res_partner/res_partner_list.dart';
import 'package:flutter_admin/pages/odoo/res_purchase/res_purchase_list.dart';
import 'package:flutter_admin/pages/odoo/sale_bid_project/sale_bid_project_list.dart';
import 'package:flutter_admin/pages/odoo/sale_inquiry_form/sale_inquiry_form_list.dart';
import 'package:flutter_admin/pages/odoo/sale_offer_form/sale_offer_form_list.dart';
import 'package:flutter_admin/pages/odoo/sale_order/order_all_track/order_all_track_list.dart';
import 'package:flutter_admin/pages/odoo/sale_order/sale_order_list.dart';
import 'package:flutter_admin/pages/odoo/sale_orderescortcode/sale_orderescortcode_list.dart';
import 'package:flutter_admin/pages/odoo/sale_orderoutstock/sale_orderoutstock_list.dart';
import 'package:flutter_admin/pages/odoo/stock_materialarrival/stock_materialarrival_list.dart';
import 'package:flutter_admin/pages/odoo/stock_materialcheck/stock_materialcheck_list.dart';
import 'package:flutter_admin/pages/odoo/stock_materialinout/stock_materialinout_list.dart';
import 'package:flutter_admin/pages/odoo/stock_picking/stock_picking_list.dart';
import 'package:flutter_admin/pages/odoo/stock_quant/team_stock_qunat/team_stock_quant_list.dart';
import 'package:flutter_admin/pages/odoo/udt_tb_docmentstock/udt_tb_docmentstock_list.dart';
import 'package:flutter_admin/pages/odoo/udt_tb_docmentstock_search/udt_tb_docmentstock_search.dart';
import 'package:flutter_admin/pages/odoo/udt_tb_docmentstock_search/udt_tb_docmentstock_search_documentno.dart';
import 'package:flutter_admin/pages/odoo/udt_tb_docmentstock_search/udt_tb_docmentstock_search_location.dart';
import 'package:flutter_admin/pages/odoo/udt_tb_docmentstock_search/udt_tb_docmentstock_search_time.dart';
// import 'package:flutter_admin/pages/odoo/udt_tb_instockrecord/udt_tb_instockrecord_list.dart';
import 'package:flutter_admin/pages/odoo/udt_tb_lendrecord/udt_tb_lendrecord_list.dart';
import 'package:flutter_admin/pages/odoo/udt_tb_workreportrecord/udt_tb_workreportrecord_list.dart';
import 'package:flutter_admin/pages/odoo/udt_tb_workreportrecordsearch/udt_tb_workreportrecordsearch_list.dart';
// import 'package:flutter_admin/pages/odoo/user/user1_list.dart';
// import 'package:flutter_admin/pages/odoo/user/user_list.dart';
import 'package:flutter_admin/pages/person/person_list.dart';
import 'package:flutter_admin/pages/role/role_list.dart';
import 'package:flutter_admin/pages/subsystem/subsystem_main.dart';
import 'package:flutter_admin/pages/userInfo/user_info_list.dart';
import 'package:flutter_admin/pages/userInfo/user_info_mine.dart';
import 'package:flutter_admin/pages/video/video_upload.dart';
import 'package:flutter_admin/utils/adaptive_util.dart';
import 'package:flutter_admin/utils/utils.dart';
import 'package:get/get.dart';

class Routes {
  static List<GetPage>? pages;
  static List<GetPage>? layoutPages;

  static Map<String, Widget> layoutPagesMap = {
    '/dashboard': Dashboard(),
    '/sAreaAgeGenderMain': SAreaAgeGenderMain(),
    '/roleList': RoleList(),
    '/personList': PersonList(),
    '/menuList': MenuMain(),
    '/userInfoList': UserInfoList(),
    '/deptMain': DeptMain(),
    '/imageUpload': ImageUpload(),
    '/videoUpload': VideoUpload(),
    '/articleMain': ArticleMain(),
    '/userInfoMine': UserInfoMine(),
    '/layout401': Page401(),
    '/layout404': Page404(),
    // '/layoutTest': MyTest(1),
    '/dictList': DictList(),
    '/message': MessageMain(),
    // '/user': UserList(),
    // 档案管理
    '/docmentstock': UdtTbDocmentstockList(),
    // 档案信息检索
    '/docmentstockSearch': UdtTbDocmentstockSearchList(),
    // 档案位置扫码查询
    '/docmentstockSearchLocation': UdtTbDocmentstockSearchLocationList(),
    // 档案编号扫码查询
    '/docmentstockSearchNo': UdtTbDocmentstockSearchDocumentnoList(),
    // 档案借阅归还查询
    '/lendrecord': UdtTbLendrecordList(),
    // 档案存放期限查询
    '/docmentstockSearchTime': UdtTbDocmentstockSearchTimeList(),
    // 电子流全员巡检
    '/electroncheckrecord': ProductElectroncheckrecordList(),
    // 生产报工信息查询
    '/workreportrecord': UdtTbWorkreportrecordList(),
    // 板材型号规格配置
    '/productTemplate': ProductTemplateList(),
    // 板材消耗数据填报
    '/productPlateconsumption': ProductPlateconsumptionList(),
    //设备采集数据查询
    "/productEquhisdata": ProductEquhisdataList(),
    // 产品工件单价配置
    '/productunitprice': ProductProductunitpriceList(),
    // 产品模具切换额定配置
    '/productMouldQuota': ProductProductmouldquotaList(),
    // '/instockrecord': UdtTbInstockrecordList(),
    // 档案位置条码打印
    '/Documentlocation': DmsDocumentlocationList(),
    // 档案项目配置
    '/documenttype': DmsDocumenttypeList(),
    // 库存信息查询
    // '/stockQuantSearch': StockQuantList(),
    // 线边库库存查询
    // '/xbkStockQuant': StockQuantList(
    //   comment: "XBK",
    // ),
    // // 原料库库存查询
    // '/ylkStockQuant': StockQuantList(
    //   comment: "YLK",
    // ),
    // // 中转库库存查询
    // '/zzkStockQuant': StockQuantList(
    //   comment: "ZZK",
    // ),
    // // 成品库库存查询
    // '/cpkStockQuant': StockQuantList(
    //   comment: "CPK",
    // ),
    // 班组线边库查询
    '/teamStockQuant': TeamStockQuantList(),
    // 库存盘点
    '/inventoryCount': StockMaterialcheckList(),
    '/subsystemList': SubsystemMain(),
    // 班组配置
    '/team': BaseTeamList(),
    '/secondLevel': OnlyText('二级菜单页面'),
    '/threeLevel': OnlyText('三级菜单页面'),
    // 生产工位打印
    '/productionstationPrint': BaseProductionstationPrintList(),
    // 产品信息打印
    '/productPrint': ProductTemplatePrintList(),
    // 采购物料到货情况查询
    '/materialarrivalSearch': StockMaterialarrivalList(),
    // 订单BOM清单查询
    '/orderBomSearch': ProductProductionorderList(),
    // 线边库出入库记录
    '/stockPicking': StockPickingList(),
    // 生产报工产量统计
    '/productWorkreportrecordYield': UdtTbWorkreportrecordsearchList(),
    // 人员岗位绩效系数配置
    '/userpostratio': ProductUserpostratioList(),

    // 销售订单查询
    '/saleOrderSearch': SaleOrderList(),
    // 发货配送跟踪
    '/saleEscortcodetrackinfo': SaleOrderescortcodeList(),
    // 订单全流程跟踪
    '/orderAllTrack': OrderAllTrackList(),

    // 原材料库收货入库记录查询
    '/companyMaterialSearch': CompanyMaterialSearchList(),
    // 车间领料单申请
    '/storesRequisition': StoresRequisitionList(),
    // 车间原材料入库
    '/workshopMaterial': WorkshopMaterialList(),
    // 车间原材料领料出库
    '/workshopPicking': WorkshopPickingList(),
    // 车间中转库移库
    '/workshopTransfer': WorkshopTransferList(),
    // 车间中转库移库记录查询
    '/workshopTransferSearch': WorkshopTransferSearchList(),
    // 车间人员绩效工资统计
    '/userhourcost': ProductUserhourcostList(),
    // 车间人员绩效工资查询
    '/userhourcostSearch': ProductUsermeritpayList(),

    // 采购订单查询
    '/purchaseOrder': PurchaseOrderList(),
    // 原材料入库接口查询
    '/stockMaterialinoutSearch': StockMaterialinoutList(),
    // 生产订单追溯
    '/mrpProduction': MrpProductionList(),
    // 成品库扫码入库
    '/finishedIn': FinishedInList(),
    // 成品库发货出库
    '/finishedOut': FinishedOutList(),
    // 成品标签库打印
    '/cpkPrint': CpkPrintList(),

    // 客户信息维护
    '/resPartner': ResPartnerList(),
    // 询价表管理
    '/saleInquiryForm': SaleInquiryFormList(),
    // 报价单管理
    '/quotation': SaleOfferFormList(),
    // 成品入库记录查询
    '/finishedInSearch': StockPickingFinishedList(),
    // 供应商评价模板
    '/purchaseEvaluationTemplate': PurchaseEvaluationTemplateList(),
    // 评价模板配置
    '/purchaseEvaluationProject': PurchaseEvaluationProjectTableList(),
    // 供应商等级规则配置
    '/purchaseSupplierLevel': PurchaseSupplierLevelList(),
    // 数据大屏
    // '/largeScreen': KanbanManagement(), // BulletinBoard(),
    '/largeScreen': CarouselEffect(), // BulletinBoard(),
    // 生产装配齐套检查
    '/mrpProductionCheck': MrpProductionCheckList(),
    // 销售订单需求
    '/mpsOrderLine': MpsOrderLineList(
      comment: 'draft',
    ),
    // 销售订单需求(取消)
    '/mpsOrderLineCancel': MpsOrderLineList(
      comment: 'cancel',
    ),
    // 物料需求明细
    '/mpsDemandLine': MpsDemandLineList(),
    // 物料汇总订购
    '/mpsReplenishment': MpsReplenishmentList(),
    // 物料在途需求
    '/mpsTransit': MpsTransitList(),
    // 销售订单排产
    '/mpsOrderLineConfirm': MpsOrderLineList(
      comment: 'purchase',
    ),
    // 人员资质证书管理
    '/dmsUserqualifications': DmsUserqualificationsList(),
    // 证书有效期查询
    '/dmsUserqualificationsSearchByTime': BaseDictionarydataList(),
    // 车间人员报工数据统计
    '/productWorkreportrecordByUser': ProductWorkreportrecordList(),
    // 招投标项目管理
    '/saleBidProject': SaleBidProjectList(),
    // 订单交货期统计分析
    '/saleOrderoutstock': SaleOrderoutstockList(),
    // 车间备货单录入打印
    '/productStockorder': ProductStockorderList(),
    // 车间补单录入打印
    '/productStockorderSupplement': ProductStockorderSupplementList(),
    // ERP物料实时库存查询
    '/ERPSearchOnTime': ERPSearchOnTimeList(),
    // '/ERPSearchOnTime': CpkPrintList(),
    // 库房安全库存配置页面（线边库）
    '/quantWarningLine': QuantWarningLineList(),

    //价格走势
    '/priceTrend': PriceTrendList(),
    // 入库
    '/locationIn': LocationInList(),
    // 出库
    '/locationOut': LocationOutList(),
    // 入库记录查询
    '/locationInSearch': LocationInSearchList(),
    // 出库记录查询
    '/locationOutSearch': LocationOutSearchList(),
    // 库存查询
    '/stockQuant': StockQuantSearchList(),
    // 华为稽查
    '/HWCheck': HWCheckList(),
    // 华为库存统计
    '/HWQuantSearch': HWQuantSearchList(),

    /**
     * 供应商管理 
     * 
     * @Author: chendeji
     * @Date: 2022-05-23 16:37:28
    */
    //供应商评价打分
    '/purchaseSupplierEvaluation': PurchaseSupplierEvaluationList(),
    // 供应商评价分析
    '/purchaseEvaluationDetail': EvaluationAnalysisList(),
    // 供应商档案信息
    '/supplier': ResPurchaseList(),
    '/purchaseQualityProblem': PurchaseQualityProblemList(),
    // 模板考评人配置
    '/templateEvaluationConfig': SupplierEvaluationTemplateConfig(),
  };
  static Map<String, List<Bindings>> layoutPageBindingMap = {
    '/templateEvaluationConfig': [CommonBindings()]
  };

  static List<String> whiteRoutes = ['/register'];

  static List<TabPage> defaultTabPage = [
    isDisplayDesktop(Cry.context)
        ? TabPage(
            id: 'dashboard',
            url: '/dashboard',
            name: 'Dashboard',
            nameEn: 'Dashboard')
        : TabPage(
            id: 'workreportrecord',
            url: '/workreportrecord',
            name: '生产报工信息查询',
            nameEn: '生产报工信息查询'),
  ];
  static List<TabPage> otherTabPage = [
    TabPage(
        id: 'userInfoMine',
        url: '/userInfoMine',
        name: '我的信息',
        nameEn: 'My Info'),
  ];

  static init() {
    layoutPages = layoutPagesMap.entries
        .map((e) => GetPage(
            name: e.key,
            page: () => e.value,
            bindings: layoutPageBindingMap[e.key]!)) //找到对应的binding
        .toList();
    pages = [
      GetPage(
        name: '/login',
        page: () => Login(),
      ),
      GetPage(
        name: '/',
        page: () => Layout(),
        middlewares: [AuthMiddleware()],
      ),
      GetPage(
        name: '/layout',
        page: () => Layout(),
        middlewares: [AuthMiddleware()],
        children: layoutPages!,
      ),
    ];
  }
}

class AuthMiddleware extends GetMiddleware {
  @override
  RouteSettings? redirect(String? route) {
    return Utils.isLogin() ? null : RouteSettings(name: '/login');
  }
}
